package com.android.oc.firstapp;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteHelper extends SQLiteOpenHelper {

	private static final String DATABASE = "db_task";

	public SQLiteHelper(Context context) {
		super(context, DATABASE, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql_1 = "CREATE TABLE task_content (_id INTEGER PRIMARY KEY AUTOINCREMENT,"
				+ "content TEXT, level INTEGER, datetime TEXT, list_id INTEGER, status INTEGER);";
		db.execSQL(sql_1);

		String sql_2 = "CREATE TABLE task_list (_id INTEGER PRIMARY KEY AUTOINCREMENT,"
				+ "listname TEXT, status INTEGER);";
		db.execSQL(sql_2);

		String sql_3 = "CREATE TABLE sys_set(_id INTEGER PRIMARY KEY AUTOINCREMENT, sort_type TEXT)";
		db.execSQL(sql_3);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		db.execSQL("DROP TABLE IF EXISTS task_content");
		db.execSQL("DROP TABLE IF EXISTS task_list");
		db.execSQL("DROP TABLE IF EXISTS sys_set");
		onCreate(db);
	}

}
